package com.youme.tools.cg.db.enums;

public enum SqlServerDataType {
  /** bigint goto Long */
  BIGINT("bigint", "Long"),
  /** int goto Integer */
  INT("int", "Integer"),
  /** smallint goto Integer */
  SMALLINT("smallint", "Integer"),
  /** tinyint goto Integer */
  TINYINT("tinyint", "Integer"),
  /** bit goto Integer */
  BIT("bit", "Integer"),
  /** decimal goto java.math.BigDecimal */
  DECIMAL("decimal", "java.math.BigDecimal"),
  /** money goto java.math.BigDecimal */
  MONEY("money", "java.math.BigDecimal"),
  /** numeric goto java.math.BigDecimal */
  NUMERIC("numeric", "java.math.BigDecimal"),
  /** smallmoney goto java.math.BigDecimal */
  SMALLMONEY("smallmoney", "java.math.BigDecimal"),
  /** float goto java.math.BigDecimal */
  FLOAT("float", "java.math.BigDecimal"),
  /** real goto java.math.BigDecimal */
  REAL("real", "java.math.BigDecimal"),
  /** date goto String */
  DATE("date", "String"),
  /** datetime2 goto String */
  DATETIME2("datetime2", "String"),
  /** datetime goto String */
  DATETIME("datetime", "String"),
  /** datetimeoffset goto String */
  DATETIMEOFFSET("datetimeoffset", "String"),
  /** smalldatetime goto String */
  SMALLDATETIME("smalldatetime", "String"),
  /** time goto String */
  TIME("time", "String"),
  /** char goto String */
  CHAR("char", "String"),
  /** varchar goto String */
  VARCHAR("varchar", "String"),
  /** text goto String */
  TEXT("text", "String"),
  /** nchar goto String */
  NCHAR("nchar", "String"),
  /** nvarchar goto String */
  NVARCHAR("nvarchar", "String"),
  /** ntext goto String */
  NTEXT("ntext", "String"),
  /** binary goto String */
  BINARY("binary", "String"),
  /** varbinary goto String */
  VARBINARY("varbinary", "String"),
  /** image goto String */
  IMAGE("image", "String");

  /** 数据库类型 */
  private String dbType;
  /** Java类型 */
  private String javaType;

  /**
   * 
   * 构造函数
   * 
   * @param dbType 数据库类型
   * @param javaType Java类型
   */
  private SqlServerDataType(String dbType, String javaType) {
    this.dbType = dbType;
    this.javaType = javaType;
  }

  /**
   * 根据数据库类型获得Java类型
   * 
   * @Title: getJavaTypeByDbType
   * @Description: 根据数据库类型获得Java类型
   * @param dbType 数据库类型
   * @return Java类型
   */
  public static String getJavaTypeByDbType(String dbType) {
    switch (dbType) {
      case "bigint":
        return BIGINT.getJavaType();
      case "int":
        return INT.getJavaType();
      case "smallint":
        return SMALLINT.getJavaType();
      case "tinyint":
        return TINYINT.getJavaType();
      case "bit":
        return BIT.getJavaType();
      case "decimal":
        return DECIMAL.getJavaType();
      case "money":
        return MONEY.getJavaType();
      case "numeric":
        return NUMERIC.getJavaType();
      case "smallmoney":
        return SMALLMONEY.getJavaType();
      case "float":
        return FLOAT.getJavaType();
      case "real":
        return REAL.getJavaType();
      case "date":
        return DATE.getJavaType();
      case "datetime2":
        return DATETIME2.getJavaType();
      case "datetime":
        return DATETIME.getJavaType();
      case "datetimeoffset":
        return DATETIMEOFFSET.getJavaType();
      case "smalldatetime":
        return SMALLDATETIME.getJavaType();
      case "time":
        return TIME.getJavaType();
      case "char":
        return CHAR.getJavaType();
      case "varchar":
        return VARCHAR.getJavaType();
      case "text":
        return TEXT.getJavaType();
      case "nchar":
        return NCHAR.getJavaType();
      case "nvarchar":
        return NVARCHAR.getJavaType();
      case "ntext":
        return NTEXT.getJavaType();
      case "binary":
        return BINARY.getJavaType();
      case "varbinary":
        return VARBINARY.getJavaType();
      case "image":
        return IMAGE.getJavaType();
      default:
        return null;
    }
  }

  /**
   * 获取：数据库类型
   */

  public String getDbType() {
    return dbType;
  }

  /**
   * 获取：Java类型
   */

  public String getJavaType() {
    return javaType;
  }

}
